#include <nice2d/action.h>

IMPLEMENT_OBJECT(Action,Object)

class ActionData
{
public:
    ActionStatus status = ActionStatus_Idel;
    ObjectWeakPointer owner;
};

Action::Action(ObjectPointer owner):
    data(new ActionData)
{
    data->owner = owner;
}

Action::~Action()
{
}

void Action::setOwner(ObjectPointer newOwner)
{
    data->owner = newOwner;
}

ObjectWeakPointer Action::getOwner()const
{
    return data->owner;
}

void Action::start()
{
    if (data->status == ActionStatus_Idel) {
        data->status = ActionStatus_Running;
        onStarted();
        onStart();
    }
}

void Action::stop()
{
    onStoped();
    onStop();
    data->status = ActionStatus_Done;
}

ActionStatus Action::getStatus() const
{
    return data->status;
}

void Action::onStart()
{
}

void Action::onStop()
{
}
